草庐IT

simplexml - PHP simplexml 实体

全部标签

php - 学说 - 实体类中的水合物收集

我有关于双向OneToManyManyToOne的问题我的实体之间的关系Device和Event.这是映射的样子://Deviceentity/***@ORM\OneToMany(targetEntity="AppBundle\Entity\Event",mappedBy="device")*/protected$events;//Evententity/***@ORM\ManyToOne(targetEntity="AppBundle\Entity\Device",inversedBy="events")*/protected$device;问题来了因为Device是一个单表继承实体

php - 减少实体中的耦合

我正在寻找一种合适的方法来减少我为Symfony2框架编写的消息包中的耦合,以便我可以在应用程序之间轻松地使用它。Message实体的每个实例都应该有一个发送者和一个接收者,instanceofSymfony\Component\Security\Core\User\UserInterface,我可以在属性的setter中很好地要求它们。但是,在设置ORM关系时,似乎我必须专门设置一个targetEntity(例如Foo\BarBundle\Entity\User),这意味着Message实体的所有进一步使用不同的应用程序要么需要更改代码,要么强行使用用户实体,这在我看来似乎不在消息包

php - 将 bool 值存储在 xml 文档中并使用 PHP SimpleXML 读取

如何在XML文档中存储bool值,以便您可以使用PHP的SimpleXML类读取它们?我有以下XML文档:samplelog和下面的php脚本来读取它:if(file_exists($filename)){$statusXml=simplexml_load_file($filename);if($statusXml){$investigating=(bool)($statusXml->investigating);echo$investigating;}}else{exit('Failedtoopen'.$filename.'.');}无论我在标签中放入什么,它总是被读取为真。我试过“

php - Doctrine2 刷新单个删除的实体

尝试删除一个实体,而不保留其他更改。请注意(虽然在这种特定情况下它并不是真正需要的)该方法不应影响操作后调用的flush()的结果。$em->remove($entity);$em->flush($entity);这将抛出一个'InvalidArgumentException'消息'必须为单个计算管理实体。我可以只使用DQL来删除;只是想知道是否有办法通过实体管理器来完成。 最佳答案 我忘了transactions,我必须测试://$eminstanceofEntityManager$em->transactional(functi

php - Doctrine ManyToMany 同一实体重复输入错误

我必须将同一个字段与不同的参数相关联。多对多:/***@ORM\ManyToMany(targetEntity="BRCN\TaxonomyBundle\Entity\Taxonomy",mappedBy="genderCategories")*/private$genders;/***@ORM\ManyToMany(targetEntity="BRCN\TaxonomyBundle\Entity\Taxonomy",inversedBy="genders")*@ORM\JoinTable(name="menu_relations",*joinColumns={@ORM\JoinCol

php - 使用 PHP simpleXml 将 child 添加到 xml

我对simpleXml和添加新项目有疑问。这是我的xml:abcdefghi我正在使用这个php代码:$xml=simplexml_load_file("myxml.xml");$sxe=newSimpleXMLElement($xml->asXML());$newItem=$sxe->addChild("items");$newItem->addChild("item",$newValue);$sxe->asXML("myxml.xml");这是结果:abcdefghijkl这为我创建了新的项目节点,但我想将项目添加到相同的现有项目节点。 最佳答案

php - 如何正确关闭 Doctrine 中的实体管理器

我在Doctrine2脚本中遇到内存泄漏问题,这显然是由一段本应消除内存问题的代码引起的。在我知道您可以(并且应该)清除实体管理器之前,我每20次迭代执行以下操作:if($this->usersCalculated%20==0){$this->em->close();$this->em=\Bootstrap::createEm();$this->loadRepositories();}Bootstrap::createEm看起来像这样:publicstaticfunctioncreateEm(){$em=EntityManager::create(Bootstrap::$connect

PHP 警告:DOMDocument::load():I/O 警告:加载外部实体失败

我阅读了有关此错误的所有信息,但未能找到任何解决方案。我有一个看起来像这样的简单页面:$xmlfile="/var/www/marees.xml";//Fichierdanslequelrécupérerlesdonnées$ent=newDOMDocument();$ent->load($xmlfile);if(!(@$ent->load($xmlfile))){echo"Unabletoload:".$xmlfile;exit();}四次中有三次随机出现此错误:PHPWarning:DOMDocument::load():I/Owarning:failedtoloadexterna

php - Symfony2 验证在实体关系/关联时不起作用

ControllerpublicfunctionindexAction(Request$request){$user=$this->container->get('security.context')->getToken()->getUser();$owner=$user->getId();$first=newFirst();$first->setOwner($owner);$second=newSecond();$second->setOwner($owner);$second->setFirst($first);$form=$this->createForm(newSecondTy

PHP:将 html 实体编码的大写字符转换为小写

如何将大写的html实体字符转换为小写?$str="É";//É$res=strtolower($str);echo$res;http://codepad.viper-7.com/Zf3RTe 最佳答案 只需使用正确的功能即可:$strLower=mb_strtolower($str,'HTML-ENTITIES');PHPMultibyteStringextensionDocs具有HTML实体的编码(参见listofallsupportedencodingsDocs)。 关于